package com.project.controller;

import com.project.bean.StudentBean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("user")
public class UserController {

    @RequestMapping("checkName")
    public String checkName(String userName) {
        if ("java".equals(userName)) {
            return "OK";
        } else {
            return "NO";
        }
    }

    @RequestMapping("getList")
    public List<StudentBean> getList() {
        List<StudentBean> list = new ArrayList<>();
        list.add(new StudentBean(2, "阿亮", LocalDate.parse("2002-12-23")));
        list.add(new StudentBean(1, "阿陈", LocalDate.parse("2003-11-11")));
        list.add(new StudentBean(3, "阿仁", LocalDate.parse("2001-03-30")));
        list.add(new StudentBean(32, "亮仔", LocalDate.parse("1998-02-12")));
        list.add(new StudentBean(22, "陈仔", LocalDate.parse("1888-08-20")));
        list.add(new StudentBean(2, "阿亮", LocalDate.parse("2002-12-23")));
        list.add(new StudentBean(1, "阿陈", LocalDate.parse("2003-11-11")));
        list.add(new StudentBean(3, "阿仁", LocalDate.parse("2001-03-30")));
        list.add(new StudentBean(32, "亮仔", LocalDate.parse("1998-02-12")));
        list.add(new StudentBean(22, "陈仔", LocalDate.parse("1888-08-20")));
        list.add(new StudentBean(2, "阿亮", LocalDate.parse("2002-12-23")));
        list.add(new StudentBean(1, "阿陈", LocalDate.parse("2003-11-11")));
        list.add(new StudentBean(3, "阿仁", LocalDate.parse("2001-03-30")));
        list.add(new StudentBean(32, "亮仔", LocalDate.parse("1998-02-12")));
        list.add(new StudentBean(22, "陈仔", LocalDate.parse("1888-08-20")));
        list.add(new StudentBean(2, "阿亮", LocalDate.parse("2002-12-23")));
        list.add(new StudentBean(1, "阿陈", LocalDate.parse("2003-11-11")));
        list.add(new StudentBean(3, "阿仁", LocalDate.parse("2001-03-30")));
        list.add(new StudentBean(32, "亮仔", LocalDate.parse("1998-02-12")));
        list.add(new StudentBean(22, "陈仔", LocalDate.parse("1888-08-20")));
        list.add(new StudentBean(2, "阿亮", LocalDate.parse("2002-12-23")));
        list.add(new StudentBean(1, "阿陈", LocalDate.parse("2003-11-11")));
        list.add(new StudentBean(3, "阿仁", LocalDate.parse("2001-03-30")));
        list.add(new StudentBean(32, "亮仔", LocalDate.parse("1998-02-12")));
        list.add(new StudentBean(22, "陈仔", LocalDate.parse("1888-08-20")));
        return list;
    }
}
